<link rel="stylesheet" href="/css/company/companyEdit.css">
<div  id="app" v-cloak>
  <div class="main">
    <div class="tip">
      <div class="tip-icon"></div>
      <div class="tip-desc">正式企业开通产品使用的期限为一年，续用请联系神州安信运营管理员。</div>
    </div>
    <div class="form-main">
      <div class="field-item">
        <div>企业名称</div>
        <div class="input-area">
          <input type="text" v-model="companyInfo.name" id="name" maxlength="22" placeholder='请填写企业名称'>
        </div>
      </div>
      <div class="field-item">
        <div>联系人</div>
        <div class="input-area">
          <input type="text" v-model="companyInfo.contactName" id="contactName" maxlength="22" placeholder='请填写企业联系人姓名'>
        </div>
      </div>
      <div class="field-item">
        <div>联系电话</div>
        <div class="input-area">
          <input type="text" v-model="companyInfo.contactPhone" id="contactPhone" maxlength="22" placeholder='请填写企业联系人电话'>
        </div>
      </div>
      <div class="field-item" v-if="companyId">
        <div>状态</div>
        <div class="input-area" :class="{'active':companyInfo.status==1,'frozen':companyInfo.status==0}">
          <input type="text" v-model="companyInfo.status==0?'冻结':'激活'" readonly>
        </div>
      </div>
      <div class="dividing-line"></div>
      <div class="field-item" v-if="companyId">
        <div>开通服务</div>
        <div class="detail-area">
          <div class="product-desc">
            <div class="title">班组小易</div>
           <!-- <div class="open-type">{{companyInfo.type==1?'正式1年':'试用1个月'}}</div>-->
          </div>
          <div class="service-time">时间：{{companyInfo.createTime | fmtDate('YYYY-MM-DD')}}至{{companyInfo.endDate | fmtDate('YYYY-MM-DD')}}</div>
          <div class="people-count">可使用人数：{{companyInfo.useCount}}</div>
        </div>
      </div>

      <div class="field-item" v-if="companyId">
        <div class="field-btn">
          <div>企业管理后台地址</div>
          <div class="reset" @click="copyAddress" id="copyBtn" data-clipboard-target="#manageServer">复制</div>
        </div>
        <div class="input-area">
          <input type="text" v-model="manageServer" id="manageServer" readonly>
        </div>
      </div>
      <div class="field-item" v-if="companyId">
        <div>登录账号</div>
        <div class="input-area">
          <input type="text" v-model="companyInfo.username" readonly>
        </div>
      </div>
      <div class="field-item" v-if="companyId">
        <div>登录密码</div>
        <div class="input-area">
          <input type="text" v-model="companyInfo.password" readonly>
        </div>
      </div>
      <div class="dividing-line" v-if="companyId"></div>
      <div class="open-list" v-if="!companyId">
        <div class="desc">开通服务</div>
        <div class="open-item">
          <div class="selected"></div>
          <div class="open-desc">班组小易</div>
        </div>
      </div>
      <div class="open-list" v-if="!companyId">
        <div class="desc">开通时间</div>
        <div class="type-item">
          <div class="open-item" :class="{'no-select':!isSelectFormal}" @click="changeStatus">
            <div :class="{'selected':isSelectFormal,'unselect':!isSelectFormal}"></div>
            <div class="open-desc">正式1年</div>
          </div>
          <div class="open-item" :class="{'no-select':isSelectFormal}" @click="changeStatus">
            <div :class="{'unselect':isSelectFormal,'selected':!isSelectFormal}"></div>
            <div class="open-desc">试用1个月</div>
          </div>
        </div>
      </div>
      <div class="dividing-line" v-if="!companyId"></div>
      <div class="field-item">
        <div class="field-btn">
          <div>组织架构名称</div>
          <div class="reset" @click="resetAlias(1)">重置</div>
        </div>
        <div class="organize-list">
          <div class="organize-item" v-for="(item,key) in companyInfo.departMentAlias">
            <div class="input-area organize-area">
              <input type="text" v-model="companyInfo.departMentAlias[key]" maxlength="20">
            </div>
            <div class="organize-level">{{levelObj[key]}}</div>
          </div>
        </div>
      </div>
      <div class="dividing-line"></div>
      <div class="field-item">
        <div class="field-btn">
          <div>角色名称</div>
          <div class="reset" @click="resetAlias(2)">重置</div>
        </div>
        <div class="role-item" v-for="(item,key) in companyInfo.roleAlias" :class="{'first':key=='companyRole'}">
          <div class="level">{{getLevel(key)}}</div>
          <div class="input-area level-area">
            <input type="text" v-model="companyInfo.roleAlias[key]['name']" maxlength="20">
          </div>
        </div>
      </div>
      <div class="dividing-line"></div>
    </div>
  </div>
  <div class="submit-btn" :class="{'flex-btn':companyId}">
    <div class="cancel" v-if="companyId" @click="cancel">取消</div>
    <div class="btn" :class="{'save':companyId}" @click="save">确定</div>
  </div>
</div>

<script>
  var companyId = '<%- companyId || '' %>';
  var agentId = '<%- agentId || '' %>';
</script>
<script src="/js/company/companyEdit.js"></script>

